package com.xusheng.cli.tools;


import com.xusheng.cli.common.constant.Constant;
import com.xusheng.cli.entity.frontUserModule.FrontUser;

/**
 * @author jy
 * @since 2021-11-02 13:28
 */
public class CurrentPlayerUserUtil {

    public static FrontUser getCurrentUser() {
        return StpPlayerUtil.isLogin() ? (FrontUser) StpPlayerUtil.getSession(false).get(Constant.PLAYER) : null;
    }

    public static Long getUserId() {
        try {
            return StpPlayerUtil.getLoginIdAsLong();
        } catch (Exception e) {
            return 0L;
        }
    }

    public static String getAccount() {
        FrontUser currentUser = getCurrentUser();
        return currentUser != null ? currentUser.getAccount() : null;
    }

}
